package com.xiaodu.jpa.entity;

import javax.persistence.*;
import java.util.Date;

/**
 * @author: dutianjie
 * @date: 2021/4/20
 * @version: v1.0.0
 * @description: 描述
 **/
@Table(name = "t_product")
@Entity(name = "product")
public class ProductEntity {


    @Id
    @Column(length = 32)
    private String pId;

    @Column(length = 255, nullable = false)
    private String pName;

    @Column(nullable = false)
    private Long price;

    @Column
    private Date scDate;

    @ManyToOne
    @JoinTable(name = "order_product", joinColumns = {@JoinColumn(name = "pId", referencedColumnName = "pId")},
            inverseJoinColumns = {@JoinColumn(name = "orderNo", referencedColumnName = "orderNo")})
    private OrderEntity orderEntity;

    @Override
    public String toString() {
        return "ProductEntity{" +
                "pId='" + pId + '\'' +
                ", pName='" + pName + '\'' +
                ", price=" + price +
                ", scDate=" + scDate +
                '}';
    }

    public String getpId() {
        return pId;
    }

    public void setpId(String pId) {
        this.pId = pId;
    }

    public String getpName() {
        return pName;
    }

    public OrderEntity getOrderEntity() {
        return orderEntity;
    }

    public void setOrderEntity(OrderEntity orderEntity) {
        this.orderEntity = orderEntity;
    }

    public void setpName(String pName) {
        this.pName = pName;
    }

    public Long getPrice() {
        return price;
    }

    public void setPrice(Long price) {
        this.price = price;
    }

    public Date getScDate() {
        return scDate;
    }

    public void setScDate(Date scDate) {
        this.scDate = scDate;
    }
}
